@use 'var';
@use 'mixins';

:root {
  --mono-font: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
}

body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell',
    'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

pre {
  font-family: inherit;
}

code {
  font-family: var(--mono-font);
  background-color: var.$code-light;
  border-radius: var.$border-radius-medium;
  padding: 0.2rem 0.4rem;
  font-size: 0.875rem;
  .szh-app--theme-dark & {
    background-color: var.$code-dark;
  }
}

p,
ul,
pre {
  margin-top: 0;
  margin-bottom: 1rem;
}

@media (min-width: var.$bp-md) {
  pre {
    white-space: pre-wrap;
  }
}

a {
  color: var.$primary-light;
  text-decoration: none;
  border-radius: var.$border-radius-small;
  @include mixins.remove-focus;
  @include mixins.focus(2px);
  &:hover {
    text-decoration: underline;
    color: var.$primary-light-lv2;
  }
  .szh-app--theme-dark & {
    color: var.$primary-dark;
    &:hover {
      color: var.$primary-dark-lv2;
    }
  }
}

input {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
}

input[type='text'] {
  font-size: 1rem;
  padding: 0.375rem 0.75rem;
  border-radius: var.$border-radius-medium;
  @include mixins.border;
  @include mixins.transition((border-color, box-shadow));
  @include mixins.remove-focus;
  @include mixins.focus(2px);
  .szh-app--theme-dark & {
    color: inherit;
    background-color: var.$background-dark;
    border-color: var.$border-dark;
    @include mixins.focus(2px, var.$focus-dark);
  }
}

label {
  cursor: pointer;
  &.checked {
    color: var.$primary-light;
    .szh-app--theme-dark & {
      color: var.$primary-dark;
    }
  }
  input[type='radio'] {
    color: inherit;
    margin-right: 0.5rem;
    font-family: 'Material Icons';
    cursor: pointer;
    @include mixins.remove-focus;
    border: none;

    &::before {
      font-size: 1.25rem;
      top: 0.3rem;
      position: relative;
      content: 'radio_button_unchecked';
    }
    &:checked::before {
      content: 'radio_button_checked';
    }
  }
}

.szh-menu-button,
.btn {
  box-sizing: border-box;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  padding: 0.375rem 0.75rem;
  line-height: 1.5;
  color: inherit;
  background-color: var.$btn-light;
  border-radius: var.$border-radius-medium;
  @include mixins.border;
  @include mixins.remove-focus;
  @include mixins.focus;

  &:hover {
    background-color: var.$btn-light-lv2;
    border-color: var.$border-hover-light;
  }
  &:active {
    background-color: var.$btn-light-lv3;
    border-color: var.$focus-light;
  }

  .example__demo & {
    min-width: 5rem;
  }

  .szh-app--theme-dark & {
    background-color: var.$btn-dark;
    border-color: var.$border-dark;
    @include mixins.focus($color: var.$focus-dark);
    &:hover {
      background-color: var.$btn-dark-lv2;
      border-color: var.$border-hover-dark;
    }
    &:active {
      background-color: var.$block-dark;
    }
  }
}

.btn-primary {
  color: white;
  background-color: var.$primary-light;
  border: none;
  &:hover,
  &:active {
    background-color: var.$primary-light-lv2;
  }
  @include mixins.focus(3px);

  .szh-app--theme-dark & {
    background-color: var.$primary-light-lv2;
    @include mixins.focus(3px);
    &:hover,
    &:active {
      background-color: var.$primary-light-lv3;
    }
  }
}

.alert-warning {
  background-color: var.$highlight-color;
  border-radius: var.$border-radius-medium;
  padding: 0.5rem 1.25rem 0.75rem 1.25rem;
}

.table {
  width: 100%;
  text-align: left;
  border-collapse: collapse;

  @media (max-width: var.$bp-md) {
    th:last-of-type {
      min-width: 20rem;
    }
  }

  tr {
    @include mixins.border(border-bottom);
    .szh-app--theme-dark & {
      border-color: var.$border-dark;
    }
  }
  th,
  td {
    padding: 1rem;
  }
  td > :last-child {
    margin-bottom: 0;
  }
  @media (max-width: var.$bp-sm) {
    & {
      display: block;
      overflow-x: auto;
      th,
      td {
        padding: 0.75rem;
      }
    }
  }
}

.external-link {
  display: inline-flex;
  align-items: center;
  svg {
    margin-left: 0.25rem;
    width: 1.25rem;
    height: 1.25rem;
  }
}
